// $('.tab').Tabs({
//     event:'click',
//     callback:function(e){
//     	isFunc(tabcallback)&&tabcallback(e)
//     }
// });


var liststring = hereDoc(function(){
/*<li>
	<div class="img">
		<a href="{0}" target="_blank"><img src="{1}" alt="{2}"></a>
	</div>
	<div class="show">
		<a href="{3}" target="_blank">{4}</a>
	</div>
</li>*/
});
/*创建模板*/
var listT = new Template(liststring);
function Tweet2dom(e){
	for (var i=0;i<30;i++)
    {
    	var homeurl = "http://www.baidu.com/";
    	var portrait = "http://static.oschina.net/uploads/user/514/1029305_100.jpg"
    	var author = "小鑫"
    	var pageurl = "http://www.baidu.com/";
    	var body = e*30+i
    	var text = listT.format(homeurl,portrait,author,pageurl,body);
    	$("#syitest ul").append(text);
    }
}

$(function(){
    sly("#syitest");
})




function sly(id){
    var $frame = $(id);
    var $wrap  = $frame.parent();
    var $ul = $wrap.find("ul");
    var $topTips = $wrap.find(".topTips");
    var $bottomTips = $wrap.find(".bottomTips");
    var loading = false;
    var fn = function(eventName){


        if(eventName == "moveStart"){
            $wrap.addClass("moveing");
        }else if(eventName == "moveEnd"){
            $wrap.removeClass("moveing");
        }

             /*继续加载*/

        if(eventName == "move" &&this.pos.cur>=this.pos.end){
            if(!loading){
                $bottomTips.css({
                    "height":(this.pos.cur-this.pos.end)+"px",
                    "line-height":(this.pos.cur-this.pos.end)+"px"
                })
            }
        }

        if(eventName == "moveEnd" &&this.pos.cur>this.pos.end+30){
            if(!loading){
                loading = true;
                $bottomTips.css({
                    "height":20+"px",
                    "line-height":20+"px"
                })
                $bottomTips.text("加载");
                $bottomTips.removeClass("open");
                Tweet2dom(20);
                this.reload();
                $bottomTips.css({
                    "height":0+"px",
                    "line-height":0+"px"
                })
                loading = false;
            }
        }else if(eventName == "move" &&this.pos.cur>this.pos.end+70){
            if(!loading){
                $bottomTips.text("够了,松开人家嘛");
                $bottomTips.addClass("open");
            }
        }else if(eventName == "move" &&this.pos.cur>this.pos.end+40){
            if(!loading){
                $bottomTips.text("快松开了");
                $bottomTips.addClass("open");
            }
        }else if(eventName == "move" &&this.pos.cur>this.pos.end+30){
            if(!loading){
                $bottomTips.text("松开加载");
                $bottomTips.addClass("open");
            }
        }else if(eventName == "move" &&this.pos.cur>this.pos.end){
            if(!loading){
                $bottomTips.text("继续拖拽加载更多");
                $bottomTips.addClass("open");
            }
        }else if(eventName == "move" &&this.pos.cur<=this.pos.end){
            $bottomTips.text("");
            $bottomTips.removeClass("open");
        }


        /*刷新*/


        if(eventName == "move" &&this.pos.cur<=0){
            if(!loading){
                $topTips.css({
                    "height":(-this.pos.cur)+"px",
                    "line-height":(-this.pos.cur)+"px"
                })
            }
        }

        if(eventName == "moveEnd" && this.pos.cur<-30){
            if(!loading){
                loading = true;
                $topTips.css({
                    "height":20+"px",
                    "line-height":20+"px"
                })
                $topTips.text("加载");
                $topTips.removeClass("open");
//                Tweet2dom(20);
//                this.reload();
                $topTips.css({
                    "height":0+"px",
                    "line-height":0+"px"
                })
                loading = false;
            }
        }else if(eventName == "move" &&this.pos.cur<-30){
                if(!loading){
                    $topTips.text("你敢松 我就敢刷!");
                    $topTips.addClass("open");
                }
        }else if(eventName == "move" &&this.pos.cur<-0){
            if(!loading){
                $topTips.text("再拉我就刷新给你看");
                $topTips.addClass("open");
            }
        }else if(eventName == "move" &&this.pos.cur>=0){
            $topTips.text("");
            $topTips.removeClass("open");
        }





    }
    var frame = $frame.sly({
        'speed': 300,
        'easing': 'easeOutExpo',
        'scrollBar': $wrap.find('.scrollbar'),
        'scrollBy': 200,
        'dragHandle': 1,
        'dynamicHandle': 1,
        'clickBar': 1,
        'mouseDragging': 1,
        'touchDragging': 1,
        'releaseSwing': 1,
        'startAt': 3,
        'elasticBounds': 1,
        'dragHandle': 1,
        'dynamicHandle': 1,
        'clickBar': 1,
        }, {
        'moveEnd': fn,
        'move': fn,
        'moveStart':fn
    }).init();

}


//<li>
//    <div class="img">
//        <a href="{0}" target="_blank"><img src="{1}" alt="{2}"></a>
//        </div>
//        <div class="show">
//            <a href="{3}" target="_blank">{4}</a>
//        </div>
//    </li>

//
//'<li>' +
//'<div class="img">' +
//'<a href="http://my.oschina.net/xioxin" target="_blank"><img src="http://static.oschina.net/uploads/user/514/1029305_100.jpg" alt="鑫酱"></a>' +
//'</div>' +
//'<div class="show">' +
//'<a href="http://my.oschina.net/xioxin" target="_blank">测试测试测试测试测试测试' +
//'' +
//'</a>' +
//'</div>' +
//'</li>'

$.